﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MaxLeaf.Common;
using System.Data;
using MaxLeaf.DB;
using System.Threading;
using System.Data.SqlClient;

namespace MaxLeaf.DAL
{
    public class RedICStockBillDeletedDALBuilder : BaseDALBuilder
    {
     
        public RedICStockBillDeletedDALBuilder()
            : base()
        {
            
            K2WDAL = new K2W.RedICStockBillDeletedDAL();
        }

        protected override bool ValidCheck(ServerInfo orgServer, ServerInfo destServer, DataRowView drvLog)
        {
            if (CvtFunc.ToInt(drvLog[DEL.LogDEL.LogStatus]) == (int)LogStatus.Delete)
            {
                return true;
            }
 

            return base.ValidCheck(orgServer, destServer, drvLog);
        }

        protected override bool ValidCheckOrgData(ServerInfo orgServer, DataRowView drvLog)
        {
            Thread.Sleep(10000);//判断是不是修改
            string strSql = "select  FInterID from  ICStockBill WHERE  FInterID=@FInterID";
            using (DBAccess dbOrgK3Con = new DBAccess(orgServer))
            {
                DataRow drData = dbOrgK3Con.GetDataFirstRow(strSql, new SqlParameter[]{
                    new SqlParameter("@FInterID",drvLog[DEL.LogDEL.KeyValue])                    
                });
                if (drData != null)
                {
                    LogManager.Debug("是假删除");
                    return false;
                }
             
            }
            return true;
        }

    }
}
